package com.facebook.drawee.generic;

import com.facebook.common.internal.Preconditions;

import java.util.Arrays;

public final class RoundingParams {
    public enum RoundingMethod {
        OVERLAY_COLOR,
        BITMAP_ONLY
    }

    public RoundingMethod mRoundingMethod;
    public boolean mRoundAsCircle;
    public float[] mCornersRadii;
    public int mOverlayColor;
    float mBorderWidth;
    int mBorderColor;
    public float mPadding;

    public RoundingParams() {
        this.mRoundingMethod = RoundingMethod.BITMAP_ONLY;
        this.mRoundAsCircle = false;
        this.mCornersRadii = null;
        this.mOverlayColor = 0;
        this.mBorderWidth = 0f;
        this.mBorderColor = 0;
        this.mPadding = 0f;
    }

    public final RoundingParams setBorder(int color, float width) {
        Preconditions.checkArgument(width >= 0f, "the border width cannot be < 0");
        this.mBorderWidth = width;
        this.mBorderColor = color;
        return this;
    }

    public final boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null
                && this.getClass() == o.getClass()
                && this.mRoundAsCircle == ((RoundingParams) o).mRoundAsCircle
                && this.mOverlayColor == ((RoundingParams) o).mOverlayColor
                && Float.compare(((RoundingParams) o).mBorderWidth, this.mBorderWidth) == 0
                && this.mBorderColor == ((RoundingParams) o).mBorderColor
                && Float.compare(((RoundingParams) o).mPadding, this.mPadding) == 0
                && this.mRoundingMethod == ((RoundingParams) o).mRoundingMethod) {
            return Arrays.equals(this.mCornersRadii, ((RoundingParams) o).mCornersRadii);
        }
        return false;
    }

    public final int hashCode() {
        int v1 = 0;
        int result = this.mRoundingMethod != null ? this.mRoundingMethod.hashCode() : 0;
        int v2 = result * 31;
        result = this.mRoundAsCircle ? 1 : 0;
        v2 = (result + v2) * 31;
        result = this.mCornersRadii != null ? Arrays.hashCode(this.mCornersRadii) : 0;
        v2 = ((result + v2) * 31 + this.mOverlayColor) * 31;
        result = this.mBorderWidth != 0f ? Float.floatToIntBits(this.mBorderWidth) : 0;
        result = ((result + v2) * 31 + this.mBorderColor) * 31;
        if (this.mPadding != 0f) {
            v1 = Float.floatToIntBits(this.mPadding);
        }
        return result + v1;
    }
}

